//- Copyright (c) 2016 Lucky Byte, Inc.
extends ../table

block form_items
  .field.three.wide
    .ui.calendar.date#start_date(data-end-with="#end_date"
      data-maxdate="#{today()}")
      .ui.input.left.icon
        i.calendar.icon
        input(type="text" name="start_date" placeholder="起始日期"
          value="#{start_date || ''}")
  .field.three.wide
    .ui.calendar.date#end_date(data-start-with="#start_date"
      data-maxdate="#{today()}")
      .ui.input.right.icon
        input(type="text" name="end_date" placeholder="结束日期"
          value="#{end_date || ''}")
        i.remove.link.icon#date_clear

  .field.eleven.wide
    .ui.buttons.right.floated.small.compact
      button.ui.green.button.labeled.icon(type="submit") 查 询
        i.icon.search
      button.ui.blue.button(type="button"
        onclick="window.location='/t40_recvr'") 返 回

block thead
  tr
    th.center.aligned
    th.center.aligned 序号
    th.center.aligned 交易时间
    th.center.aligned 商户编号
    th.center.aligned 商户名称
    th.center.aligned 终端编号
    th.center.aligned 交易金额
    th.center.aligned 跟踪号
    th.center.aligned 追付金额
    th.center.aligned 收款账户
    th.center.aligned 追付用户
    th.center.aligned 复核用户
    th.center.aligned 完成时间
    th.center.aligned 备 注

block tbody
  each record in records
    - var tr_color = ''
    case record.status
      when 1
        - tr_color = 'warning'
      when 2
        - tr_color = ''
      when 3
        - tr_color = 'error'

    tr(class="#{tr_color}")
      td.center.aligned.collapsing
        if record.done
          i.icon.checkmark.green.link(data-content="已追付"
            data-variation="small very wide")
        else
          i.icon.wait.orange.link(data-content="尚未追付，等待调度"
            data-variation="small very wide")
      td.center.aligned.collapsing= record.serial
      td.center.aligned.collapsing= record.tr1_systime.format('MM-DD HH:mm:ss')
      td.center.aligned.collapsing= record.tr1_info[0]
      td.center.aligned.collapsing= record.tr1_mername
      td.center.aligned.collapsing= record.tr1_info[1]
      td.center.aligned.collapsing= fmtamt2(record.tr1_info[2])
      td.center.aligned.collapsing
        a(href="/trlist?keyword=#{record.tr_uuid_1}" +
          "&start_date=#{record.tr1_systime.format('YYYY-MM-DD')}" +
          "&end_date=#{record.tr1_systime.format('YYYY-MM-DD')}"
          data-content="点击查看原交易流水"
          data-variation="small very wide")= record.tr1_info[3]
      td.center.aligned.collapsing= fmtamt(record.t40_amt)
      td.center.aligned.collapsing
        = record.acct_no.substring(0, 4)
        |  .. 
        = record.acct_no.substring(record.acct_no.length - 4)
      td.center.aligned.collapsing= record.input_user || '系统自动'
      td.center.aligned.collapsing= record.check_user || '系统自动'
      td.center.aligned.collapsing
        if record.done
          a(href="/trlist?keyword=#{record.done_uuid}" +
            "&start_date=#{start_date}&end_date=#{end_date}" +
            "&incoming=false"
            data-content="点击查看追付交易流水"
            data-variation="small very wide")
            = record.done_time.format('MM-DD HH:mm:ss')
        else
          | 尚未完成
      td.center.aligned= record.notes
  else
    td.center.aligned.warning(colspan="14") 无数据
